import { getQuestDetailAPI } from '@/apis/quest'
import { useRoute } from 'vue-router'
import { ref, onMounted } from 'vue'

export default function useQuestInfo() {

  const route = useRoute()
  const questInfo = ref(null)

  onMounted(async () => await retrieveData())

  async function retrieveData() {
    const res = await getQuestDetailAPI(route.params.id).catch(() => null)
    if (res) questInfo.value = res.data
  }

  return {
    questInfo
  }
}